package com.hamizhong.iflowers.web.action;

import com.hamizhong.iflowers.service.IUserService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.utils.MyTools;
import com.hamizhong.iflowers.web.base.MyBaseAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.UserVO;

public class UserCenterAction extends MyBaseAction {
	private IUserService iUserService = null;
	
	public IUserService getiUserService() {
		return iUserService;
	}
	public void setiUserService(IUserService iUserService) {
		this.iUserService = iUserService;
	}

	@Override
	protected String doRequest() {
		UserVO loginUserVO = (UserVO) getSSN().getAttribute(MyConstants.IFLOWERS_LOGIN_USER_VO);
		IOPResultDto<IObjectVO> dto = iUserService.findByEmail(loginUserVO.getUserEmail());
		if(dto.isSuccess()) {
			UserVO userVO = dto.getFirstResult().getUserVOList().get(0);
			userVO.setCreateDateStr(MyTools.formatDttm2YYYY_MM_DD(userVO.getCreateDate()));
			getRQ().setAttribute("userVO", userVO);
			return SUCCESS;
		}else {
			return ERROR;
		}
	}

}
